﻿using UnityEngine;
using System.Collections;

public class PlayerBehaviour : MonoBehaviour {

	public Transform mesh;
	public float forceFly;
	private Animator animatorPlayer;

	private float currentTimeToAnim;
	private bool inAnim;

	// Use this for initialization
	void Start () {
		animatorPlayer = mesh.GetComponent<Animator>();
	
	}
	
	// Update is called once per frame
	void Update () {

		if(Input.GetMouseButtonDown(0))
		  {
			animatorPlayer.SetBool("callFly", true);
			inAnim = true;
			rigidbody2D.AddForce(new Vector2(0, 10)*forceFly);
		  }
		if(inAnim)
		{
			currentTimeToAnim += Time.deltaTime;

			if(currentTimeToAnim > 0.2f)
			{
				currentTimeToAnim = 0;
				inAnim = false;

			}
			animatorPlayer.SetBool("callFly", inAnim);
	
		}
	
	}
}
